import 'package:characters/characters.dart';

void main() {
  // Numbers 示例
  print('Numbers 示例:');
  var x = 1;
  var hex = 0xDEADBEEF;
  print('整数 x: $x, 十六进制 hex: $hex');

  var y = 1.1;
  var exponents = 1.42e5;
  print('浮点数 y: $y, 指数表示 exponents: $exponents');

  num z = 1;
  z += 2.5;
  print('num 类型 z: $z');

  double aDouble = 1;
  print('整数自动转换为浮点数 aDouble: $aDouble');

  var one = int.parse('1');
  var onePointOne = double.parse('1.1');
  var oneAsString = 1.toString();
  var piAsString = 3.14159.toStringAsFixed(2);
  print('字符串转数字 one: $one, onePointOne: $onePointOne');
  print('数字转字符串 oneAsString: $oneAsString, piAsString: $piAsString');

  assert((3 << 1) == 6);
  assert((3 | 4) == 7);
  assert((3 & 4) == 0);
  print('位运算 (3 << 1): ${3 << 1}, (3 | 4): ${3 | 4}, (3 & 4): ${3 & 4}');

  const msPerSecond = 1000;
  const secondsUntilRetry = 5;
  const msUntilRetry = secondsUntilRetry * msPerSecond;
  print('编译时常量 msUntilRetry: $msUntilRetry');

  var n1 = 1_000_000;
  var n2 = 0.000_000_000_01;
  var n3 = 0x00_14_22_01_23_45;
  var n4 = 555_123_4567;
  var n5 = 100__000_000__000_000;
  print('带分隔符的数字 n1: $n1, n2: $n2, n3: $n3, n4: $n4, n5: $n5');

  // Strings 示例
  print('\nStrings 示例:');
  var s1 = 'Single quotes work well for string literals.';
  var s2 = "Double quotes work just as well.";
  var s3 = 'It\'s easy to escape the string delimiter.';
  var s4 = "It's even easier to use the other delimiter.";
  print('s1: $s1, s2: $s2, s3: $s3, s4: $s4');

  var s = 'string interpolation';
  var sInterpolated1 = 'Dart has $s, which is very handy.';
  var sInterpolated2 =
      'That deserves all caps. ${s.toUpperCase()} is very handy!';
  print('字符串插值 sInterpolated1: $sInterpolated1');
  print('字符串插值 sInterpolated2: $sInterpolated2');

  var sConcatenated1 =
      'String '
      'concatenation'
      " works even over line breaks.";
  var sConcatenated2 = 'The + operator ' 'works, as well.';
  print('字符串连接 sConcatenated1: $sConcatenated1');
  print('字符串连接 sConcatenated2: $sConcatenated2');

  var sMultiLine1 = '''You can create
multi-line strings like this one.''';
  var sMultiLine2 = """This is also a
multi-line string.""";
  print('多行字符串 sMultiLine1: $sMultiLine1');
  print('多行字符串 sMultiLine2: $sMultiLine2');

  var sRaw = r'In a raw string, not even \n gets special treatment.';
  print('原始字符串 sRaw: $sRaw');

  // Booleans 示例
  print('\nBooleans 示例:');
  var fullName = '';
  var hitPoints = 0;
  var unicorn;
  var iMeantToDoThis = 0 / 0;
  print('fullName.isEmpty: ${fullName.isEmpty}');
  print('hitPoints == 0: ${hitPoints == 0}');
  print('unicorn == null: ${unicorn == null}');
  print('iMeantToDoThis.isNaN: ${iMeantToDoThis.isNaN}');

  // Runes and grapheme clusters 示例
  print('\nRunes and grapheme clusters 示例:');
  var hi = 'Hi 🇩🇰';
  print('字符串 hi: $hi');
  print('字符串 hi 的最后一个字符: ${hi.characters.last}');

  // Symbols 示例
  print('\nSymbols 示例:');
  var radixSymbol = #radix;
  var barSymbol = #bar;
  print('radix 的 Symbol: $radixSymbol, bar 的 Symbol: $barSymbol');
}
